/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.eps.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Luis_Angel
 */
@Entity
@Table(name = "DetalleComprobantePago")
@NamedQueries({
    @NamedQuery(name = "DetalleComprobantePago.findAll", query = "SELECT d FROM DetalleComprobantePago d"),
    @NamedQuery(name = "DetalleComprobantePago.findByIdComprobante", query = "SELECT d FROM DetalleComprobantePago d WHERE d.detalleComprobantePagoPK.idComprobante = :idComprobante"),
    @NamedQuery(name = "DetalleComprobantePago.findByNroOrden", query = "SELECT d FROM DetalleComprobantePago d WHERE d.detalleComprobantePagoPK.nroOrden = :nroOrden"),
    @NamedQuery(name = "DetalleComprobantePago.findByCorrelativo", query = "SELECT d FROM DetalleComprobantePago d WHERE d.detalleComprobantePagoPK.correlativo = :correlativo"),
    @NamedQuery(name = "DetalleComprobantePago.findByMontoComprobante", query = "SELECT d FROM DetalleComprobantePago d WHERE d.montoComprobante = :montoComprobante")})
public class DetalleComprobantePago implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected DetalleComprobantePagoPK detalleComprobantePagoPK;
    @Column(name = "monto_comprobante")
    private BigDecimal montoComprobante;
    @JoinColumn(name = "id_comprobante", referencedColumnName = "id_comprobante", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private ComprobantePago comprobantePago;
    @JoinColumns({
        @JoinColumn(name = "nro_orden", referencedColumnName = "nro_orden", insertable = false, updatable = false),
        @JoinColumn(name = "correlativo", referencedColumnName = "correlativo", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private DetalleOrden detalleOrden;

    public DetalleComprobantePago() {
    }

    public DetalleComprobantePago(DetalleComprobantePagoPK detalleComprobantePagoPK) {
        this.detalleComprobantePagoPK = detalleComprobantePagoPK;
    }

    public DetalleComprobantePago(long idComprobante, String nroOrden, int correlativo) {
        this.detalleComprobantePagoPK = new DetalleComprobantePagoPK(idComprobante, nroOrden, correlativo);
    }

    public DetalleComprobantePagoPK getDetalleComprobantePagoPK() {
        return detalleComprobantePagoPK;
    }

    public void setDetalleComprobantePagoPK(DetalleComprobantePagoPK detalleComprobantePagoPK) {
        this.detalleComprobantePagoPK = detalleComprobantePagoPK;
    }

    public BigDecimal getMontoComprobante() {
        return montoComprobante;
    }

    public void setMontoComprobante(BigDecimal montoComprobante) {
        this.montoComprobante = montoComprobante;
    }

    public ComprobantePago getComprobantePago() {
        return comprobantePago;
    }

    public void setComprobantePago(ComprobantePago comprobantePago) {
        this.comprobantePago = comprobantePago;
    }

    public DetalleOrden getDetalleOrden() {
        return detalleOrden;
    }

    public void setDetalleOrden(DetalleOrden detalleOrden) {
        this.detalleOrden = detalleOrden;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (detalleComprobantePagoPK != null ? detalleComprobantePagoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DetalleComprobantePago)) {
            return false;
        }
        DetalleComprobantePago other = (DetalleComprobantePago) object;
        if ((this.detalleComprobantePagoPK == null && other.detalleComprobantePagoPK != null) || (this.detalleComprobantePagoPK != null && !this.detalleComprobantePagoPK.equals(other.detalleComprobantePagoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "suministros.ejb30.entity.DetalleComprobantePago[detalleComprobantePagoPK=" + detalleComprobantePagoPK + "]";
    }

}
